import request from '@/utils/request.js'
// import { request2 } from '@/utils/request'

export function getCode(mobile) {
  request({
    url: '/v1_0/sms/codes/' + mobile
  })
}

export function login(data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data
  })
}

export function getUser() {
  return request({
    url: '/v1_0/user'
  })
}

export function getUserChannel() {
  return request({
    url: '/v1_0/user/channels'
  })
}

export function addchannelItem(channel) {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [channel]
    }
  })
}

export function remchannelItem(id) {
  return request({
    url: '/v1_0/user/channels' + id,
    method: 'DELETE'
  })
}

// 获取个人资料
export function getUserinfo(id) {
  return request({
    url: '/v1_0/user/profile'
  })
}

export function updatename(data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}

export function updategender(data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}

export function updatebirthday(data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}

export function updatephoto(data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

